﻿using System.Linq;
using System.Net;
using System.ServiceModel.Syndication;

namespace RssReaderTemplate.Model.Mappers
{
    public class _TemplateSafeApplicationName_ItemMapper : PartialMapper
    {
        public override string MapTitle(SyndicationItem item)
        {
            return item.Title.Text;
        }

        public override string MapContent(SyndicationItem item)
        {
            return HttpUtility.HtmlDecode(item.Summary.Text);
        }

        public override string MapAuthor(SyndicationItem item)
        {
            var author = item.Authors.FirstOrDefault();
            return author == null ? "" : author.Email;
        }

        public override System.DateTime MapPublishDate(SyndicationItem item)
        {
            return item.PublishDate.DateTime;
        }
    }
}
